// Project name:JavaRedis
// Creator:muhong
// Date time:2023/2/7,5:23 下午
// Name:FastThreadRunnable

package org.gmh.util.concurrent;

public class FastThreadLocalRunnable implements Runnable {

    private final Runnable runnable;

    FastThreadLocalRunnable(Runnable runnable) {
        this.runnable = runnable;
    }

    @Override
    public void run() {
        try {
            runnable.run();
        } finally {
            // 清理FastThreadLocal
        }
    }

    static Runnable wrap(Runnable runnable) {
        return runnable instanceof FastThreadLocalRunnable ? runnable : new FastThreadLocalRunnable(runnable);
    }
}
